<template>
  <div @click.stop="handleClick">
    <slot />
  </div>
</template>
<script setup>
import { useUserStore } from '@/store'
import mitt from '@/utils/mitt'
import { Message } from '@arco-design/web-vue'
import { storeToRefs } from 'pinia'
const { token } = storeToRefs(useUserStore())
const props = defineProps({
  needLogin: {
    type: Boolean,
    default: true
  }
})
const emits = defineEmits(['onClick'])
const handleClick = () => {
  if (token.value || !props.needLogin) {
    emits('onClick')
  } else {
    mitt.emit('setLoginModal', true)
    Message.info('请先登录')
  }
}
</script>
<style lang="less" scoped></style>
